package com.imcrl.core.config
{
	import flash.utils.Dictionary;
	
	import mx.utils.StringUtil;
	
	/**
	* config.xml配置文件中的前缀节点;
	 * @author crl
	 * 
	 */
	public class ResourceSection extends AbstractSection
	{
		/**
		 * 是否加入版本后缀
		 */		
		public var v:Boolean;
		
		/**
		 * 加在配置value的前缀 
		 */		
		protected var prefix:String;
		
		/**
		 * 是否值被初始化过; 
		 */		
		protected var _inited:Boolean=false;
		
		public function ResourceSection()
		{
		}
		
		override public function bindXML(xml:XML):void
		{
			super.bindXML(xml);
			prefix=xml.@prefix;
			v = StringUtil.trim(xml.@v) !="";           
		}
		
		override public function get value():String{
			if(_inited){
				return _value;
			}
			
			
			_inited=true;
			
			if(prefix !=""){
				var prefixes:Dictionary=conf.config[Configuration.PREFIXS];
				var prefixSecion:PrefixSection=prefixes[prefix];
				if(prefixSecion)_value=prefixSecion.value+_value;
			}
			
			
			if(v){
				_value = _value + "?v=" + this.conf.version;
			}
			return _value;
		}
		
	}
}

